import { Injectable } from "@angular/core";
import { HttpClient, HttpParams } from "@angular/common/http";
import { Observable } from "rxjs";
@Injectable({
  providedIn: 'root'
})
export class CustomerShopService {
  // 门店详情
  public DETAILS_URL = "/customer/storeList";
  
  // 门店信息审核
  public AUDIT_URL = "/customer/update";

  // 字典查询子列表
  public dictUrl = '/dict/detail';

  // 查询社会统一信用代码是否存在
  verifUsccUrl = '/customer/fansLIsUscc';

  // 重置审核状态
  resetStatusUrl = '/customer/updateUserCompanyStatus';

  // 商家地图属性修改
  updateMapAttributeUrl = '/customer/updateMapName';
  
  constructor(public httpClient: HttpClient) { }
  
  // 门店详情
  public details(json: any | null): Observable<any> {
    return this.httpClient.post(this.DETAILS_URL, json);
  }

  // 门店信息审核
  public audit(json: any | null): Observable<any> {
    return this.httpClient.post(this.AUDIT_URL, json);
  }

  // 查询社会信用代码是否存在
  verifUsccData(params: any) {
    return this.httpClient.post(this.verifUsccUrl, params).toPromise();
  }

  // 重置审核状态
  resetStatusData(params: any) {
    return this.httpClient.get(this.resetStatusUrl, { params: params }).toPromise();
  }

  // 商家地图属性修改
  updateMapAttributeData(params: any) {
    return this.httpClient.post(this.updateMapAttributeUrl, params).toPromise();
  }

  /**
   * 字典查询
   * @param parentKey 
   * @returns 
   */
  public dictListData(parentKey: any) {
    let params: any = {
      parentKey: parentKey,
      pageNum: 0,
      pageSize: 0
    };
    return this.httpClient.get(this.dictUrl, { params: params }).toPromise();
  }
}
